#!/bin/bash

#DB
export database=zabbix
export passwd="Esxi0000."
export database_ip=192.168.236.131
export database_port=3306
export user=root

#Zabbix Port
export zabbix_server_port=10051
export zabbix_web_port=80

#main
case $1 in
start)
	docker-compose up -d 
	docker-compose ps    
	#Zabbix Server is not running.
	#反斜杠转义"$"、"[]","\s*"匹配任意数量的空格,".*"匹配任意数量的任意字符
	docker exec zabbix_web sed -i "s/\$DB\['SERVER'\]\s*=\s*.*/\$DB\['SERVER'\]    = '${database_ip}';/g" /etc/zabbix/web/zabbix.conf.php
	docker exec zabbix_web sed -i "s/\$ZBX_SERVER\s*=\s*.*/\$ZBX_SERVER     = '${database_ip}';/g" /etc/zabbix/web/zabbix.conf.php
	docker exec zabbix_web cat /etc/zabbix/web/zabbix.conf.php | grep ${database_ip}
	docker restart zabbix_web
	;;
stop)
    docker-compose stop
    ;;
rm)
    docker-compose rm
    ;;
logs)
	docker-compose logs
	;;
*)
	echo CMD is start/stop/rm
	;;
esac

